|
|
|
|
|
|
|
drives. The purpose of the machine is to allow people on the LAN to connect and install software. However, because people are always swapping and borrowing CD-ROMs, it is hard to know at a given time which CD is in each drive. It would be great if there was a way to automatically keep track of the CDs on a Web page. Fortunately, with Personal Web Server and Active Server Pages, this task is very easy to accomplish. |
|
|
|
|
|
|
|
|
You use VBScript's FileSystemObject to determine the volume labels of each drive on a computer. By placing this VBScript code in an ASP file where the code executes on the server, you can have the volume labels of the server's CD drives displayed on a remote browser. The code, shown in Listing 31.2, is fairly straightforward. |
|
|
|
|
|
|
|
|
Listing 31.2 ASPDEMO.ZIPVOLLABEL.ASP |
|
|
|
|
|
|
|
|
<HTML>
<BODY>
<H1>Drive List</H1><HR>
<%
Dim objFileSys
Dim objDrives
Dim objDrive
'IGNORE DISK NOT READY ERRORS
On Error Resume Next
'CREATE REFERENCES TO FILE SYSTEM AND DRIVES COLLECTION
Set objFileSys = Server.CreateObject("Scripting.FileSystemObject")
Set objDrives = objFileSys.Drives
'DISPLAY VOLUME LABELS
For Each objDrive in objDrives
if objDrive.DriveLetter > "C" Then
Response.Write ("The CD in Drive " & objDrive.DriveLetter)
Response.Write (" is " & objDrive.VolumeName & ". <BR> ")
End If
Next
'CLEAN UP!
Set objDrives = Nothing
Set objFileSys = Nothing
%>
</BODY>
</HTML> |
|
|
|
|
|
|
|
|
When a user accesses this page, the section of VBScript code executes on the Web server. The Web page in Listing 31.2 accomplishes its purpose, but leaves a lot to be desired in terms of formatting. It would appear neater if you used some HTML formatting codes, such as the <TABLE> tag. This can be easily accomplished by modifying the Response.Write statements. (As you probably have gathered by now, Response.Write is used in an ASP file to send HTML back to the browser.) |
|
|
|
|
|